CC=gcc
CXX=g++
VERSION=alpha

LIB_DODO_PLOT=-I./src
LIB_CAIRO=-I/usr/include/cairo -I/usr/include/cairomm-1.0 -I/usr/include/sigc++-2.0 -lcairomm-1.0 -lcairo

LIB_SHAPE=-I./include/shapelib -L./lib -lshapelib

LIB_BOOST=

ALL_H = ./src/dodo_plot/dodo_plot.h \
	./src/dodo_plot/kernel/basic_elements.h \
	./src/dodo_plot/kernel/point.h \
	./src/dodo_plot/kernel/position.h \
	./src/dodo_plot/kernel/color.h \
	./src/dodo_plot/kernel/font.h \
	./src/dodo_plot/kernel/colormap.h \
	./src/dodo_plot/kernel/basic_utils.h \
	./src/dodo_plot/kernel/operation.h \
	./src/dodo_plot/kernel/canvas.h \
	./src/dodo_plot/kernel/plotter.h \
	./src/dodo_plot/kernel/plotter.tcc \
	./src/dodo_plot/kernel/combi_pic.h \
	./src/dodo_plot/kernel/frame_pic.h \
	./src/dodo_plot/kernel/pic.h  \
	./src/dodo_plot/kernel/picture.h  \
	./src/dodo_plot/kernel/plotfwd.h  \
	./src/dodo_plot/kernel/p_node.h \
	./src/dodo_plot/widget/cross.h \
	./src/dodo_plot/widget/blank.h \
	./src/dodo_plot/widget/label.h \
	./src/dodo_plot/widget/image.h \
	./src/dodo_plot/widget/image.tcc \
	./src/dodo_plot/widget/plot.h \
	./src/dodo_plot/widget/plot.tcc \
	./src/dodo_plot/widget/axis.h \
	./src/dodo_plot/widget/colorbar.h \
	./src/dodo_plot/widget/vector_field.h \
	./src/dodo_plot/projector/projector.h \
	./src/dodo_plot/projector/null_projector.h \
	./src/dodo_plot/projector/linear_2d_projector.h 

MAP_H = ./src/dodo_plot/map/lambert.h \
	./src/dodo_plot/map/plain_projection.h \
	./src/dodo_plot/map/map_data.h \
	./src/dodo_plot/map/map.h \
	./src/dodo_plot/map/map.tcc \
	./src/dodo_plot/map/map_grid.h \
	./src/dodo_plot/map/map_grid.tcc \
	./src/dodo_plot/map/map_utils.h

ALL_CPP = ./src/dodo_plot/kernel/point.cpp \
	  ./src/dodo_plot/kernel/position.cpp \
	./src/dodo_plot/kernel/basic_utils.cpp \
	./src/dodo_plot/kernel/operation.cpp \
	./src/dodo_plot/kernel/canvas.cpp \
	./src/dodo_plot/kernel/plotter.cpp \
	./src/dodo_plot/kernel/combi_pic.cpp \
	./src/dodo_plot/kernel/frame_pic.cpp \
	./src/dodo_plot/kernel/picture.cpp  \
	./src/dodo_plot/kernel/p_node.cpp \
	./src/dodo_plot/widget/cross.cpp \
	./src/dodo_plot/widget/label.cpp\
	./src/dodo_plot/widget/image.cpp \
	./src/dodo_plot/widget/blank.cpp \
	./src/dodo_plot/widget/plot.cpp \
	./src/dodo_plot/widget/axis.cpp \
	./src/dodo_plot/widget/colorbar.cpp
#
MAP_CPP = ./src/dodo_plot/map/lambert.cpp \
	  ./src/dodo_plot/map/plain_projection.cpp \
	  ./src/dodo_plot/map/map_data.cpp 

ALL_OBJ = point.o \
	  position.o \
	  basic_utils.o \
	  operation.o \
	  canvas.o \
	  plotter.o \
	  combi_pic.o \
	  frame_pic.o \
	  picture.o \
	  p_node.o \
	  cross.o \
	  label.o \
	  image.o \
	  blank.o \
	  axis.o \
	  plot.o \
	  colorbar.o

MAP_OBJ = lambert.o \
	  map_data.o \
	  plain_projection.o 

ALL_INCLUDE_FOLDER = ./src/dodo_plot/dodo_plot.h \
	./src/dodo_plot/kernel \
	./src/dodo_plot/widget \
	./src/dodo_plot/projector

MAP_INCLUDE_FOLDER = ./src/dodo_plot/map

#
#
.PHONY:lib
lib :
	$(CXX) -fPIC -c $(ALL_CPP) $(LIB_DODO_PLOT) $(LIB_CAIRO) $(LIB_BOOST) -lm
	ar ru libdodo_plot-$(VERSION).a $(ALL_OBJ)
	$(CXX) -shared -fPIC -o libdodo_plot-$(VERSION).so $(ALL_OBJ) $(LIB_DODO_PLOT) $(LIB_CAIRO) $(LIB_BOOST) -lm
	mkdir -p lib
	mv -f *.a *.so lib/
	mkdir -p include/dodo_plot
	cp -rf $(ALL_INCLUDE_FOLDER) include/dodo_plot/
	rm -f include/*.cpp include/*/*.cpp include/*/*/*.cpp
	rm -f $(ALL_OBJ)
	echo "\n Done~\n"

map_lib :
	$(CXX) -fPIC -c $(MAP_CPP) $(LIB_DODO_PLOT) $(LIB_SHAPE) $(LIB_CAIRO) $(LIB_BOOST) -lm
	ar ru libdodo_plot_map-$(VERSION).a $(MAP_OBJ)
	$(CXX) -shared -fPIC -o libdodo_plot_map-$(VERSION).so $(MAP_OBJ) $(LIB_DODO_PLOT) $(LIB_CAIRO) $(LIB_BOOST) -lm
	mkdir -p lib
	mv -f *.a *.so lib/
	mkdir -p include/dodo_plot
	cp -rf $(MAP_INCLUDE_FOLDER) include/dodo_plot/
	rm -f include/*.cpp include/*/*.cpp include/*/*/*.cpp
	rm -f $(MAP_OBJ)
	echo "\n Done~\n"

.PHONY:clean				
clean :
	rm -f $(ALL_OBJ) $(MAP_OBJ) *.a *.so
	
